<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="util" uri="/WEB-INF/kdd-util.tld" %>
<%@taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<sec:authorize access="isAuthenticated()">
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        </head>
        <body>
            <jsp:include page="menu.jsp" />
            <script type="text/javascript">
                $(function() { 
                    var t = $('table#listtable')
                    $("#filter").keyup(function() {
                        $.uiTableFilter( t, this.value );
                    })
                });  
            </script>
            <h6><spring:message code="msg.settings" /></h6>
            <c:url var="action" value="/settings" />
            <form:form class="well notfull form-horizontal" action="${action}" method="POST" modelAttribute="user">
                <fieldset>
                    <div class="control-group">
                        <label class="control-label"><spring:message code="msg.name" />:</label>
                        <div class="controls">
                            <form:input class="input-xlarge" path="username" disabled="true" /></br >
                            <form:errors cssClass="label label-important" path="username"/>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label"><spring:message code="msg.password" />:</label>
                        <div class="controls">
                            <form:password class="input-xlarge" path="password" />
                            <br />
                            <form:errors path="password" cssClass="label label-important" />
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label"><spring:message code="msg.repassword" />:</label>
                        <div class="controls">
                            <form:password class="input-xlarge" path="rePassword" />
                            <br />
                            <form:errors path="rePassword" cssClass="label label-important" />
                        </div>
                    </div>
                    <div class="form-actions">
                        <button type="submit" class="btn btn-primary"><spring:message code="msg.save" /></button>
                        <button type="reset" class="btn btn-warning"><spring:message code="msg.reset" /></button>
                    </div>
                </fieldset>
            </form:form>
            <div class="well notfull">
                <spring:message code="msg.language" />:<br /><br />
                <a href="<c:url value='/localechange/de' />"><spring:message code="msg.german" /></a><br />
                <a href="<c:url value='/localechange/en' />"><spring:message code="msg.english" /></a>
            </div>
            <input type="text" id="filter" placeholder="Filter" />
            <table id="listtable" class="table table-striped table-bordered table-condensed notfull">
                <thead>
                    <tr>
                        <th><spring:message code="msg.subproject" /></th>
                        <th class="creationdate"><spring:message code="msg.created" /></th>
                        <th class="follow"><spring:message code="msg.follow" /></th>
                    </tr>
                </thead>
                <tbody>
                    <c:forEach items="${sharedSubProjects}" var="p">
                        <tr>
                            <td>${p.name}</td>
                            <td><fmt:formatDate value="${p.creationDate}" pattern="MM/dd/yyyy HH:mm"/></td>
                            <c:choose>
                                <c:when test="${util:isFollowProject(loggedUser, p)}">
                                    <td><a class="btn btn-mini btn-info" href="<c:url value='/settings/unfollow/${p.id}' />"><spring:message code="msg.unfollow" /></a></td>
                                </c:when>
                                <c:otherwise>
                                    <td><a class="btn btn-mini btn-info" href="<c:url value='/settings/follow/${p.id}' />"><spring:message code="msg.follow" /></a></td>
                                </c:otherwise>
                            </c:choose>
                        </tr>
                    </c:forEach>
                </tbody>
            </table>
            <jsp:include page="foot.jsp" />
        </sec:authorize>